﻿using System.Globalization;
using System.Threading;
using System.Web.Mvc;

namespace ZSoft.Telegram.UI.Web.Infrastructure.Filters
{
    public class LocalizedAttribute: ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            string cultureCode = filterContext.RouteData.Values["Culture"].ToString();

            if (cultureCode != null)
            {
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureCode);
            }
            
            base.OnActionExecuting(filterContext);
        }
    }
}